<?php

class Userv2info_model extends Base_Model
{
    const TABLE = 'user_v2_userinfo';

    public function __construct()
    {
        $this->load->database();
    }

    /**
     * 获取信息
     *
     * @param $data
     * @return mixed
     */
    public function getUserV2Info($data=array())
    {
        $this->db->select(
                          'uvu.userGender,
        		           uvu.userFamily,
        		           uvu.userName,
        		           u.userName as realName,
                           u.telCode,
                           u.userId,
        		           u.telNum,
        		           u.userIcon,
        		           uvu.userPhone,
                           uvu.introduction,
                           uvu.userAge,
                           uvu.nationality,
                           uvu.resideCity,
                           uvu.resideTime
                           '
                          )
                 ->from('user_v2_userinfo as uvu');
        $this->db->join('user_v2 as u', 'u.uid = uvu.uid', 'left');
        $this->db->where($data);
        $query=$this->db->get()->row_array();
        if(!empty($query)){
        	//是否已http开头
        	if(strpos(trim($query['userIcon']),'http')!==0){
        		$query['userIcon']=$this->img($query['userIcon']);
        	}
        }
	    
		return $query;
	}

    /**
     *
     * 修改会员信息
     * @param $data
     * @param $where
     * @return CI_DB_active_record|CI_DB_result
     */
    public function editUserInfo($data, $where)
    {
        return $this->db->update(self::TABLE, $data, $where);
    }
    /**
     * 创建userv2_info
     *
     * @param $data
     * @return int
     */
    public function createUserV2Info($data)
    {
        $this->db->insert(self::TABLE, $data);
        return $this->db->insert_id();
    }

}
